<?php

use think\facade\Route;

// 后台路由
Route::group(function(){
    Route::group(function(){
        // 安装
        Route::get('/install','/index');
        Route::get('/install_monitor','/monitor');
        Route::get('/install_configure','/configure');
        Route::post('/install_create','/create');
        Route::any('/install_exec','/install');
        Route::get('/install_check','/installCompleteCheck');
        Route::get('/install_done_complete','/completeCheck');
        Route::post('/install_testPass','/testPass');
        Route::get('/install_complete','/complete');

    })->prefix(config('route.admin').'.systemInstall');
    // 登录注册
    Route::post('/account/login',config('route.admin').'.account/login');

    Route::group(function(){

        // 管理员管理
        Route::group('admin',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
            // 当前管理员权限
            Route::get('/self','/self');
            // 当前管理员权限
            Route::post('/selfUpdate','/selfUpdate');
        })->prefix(config('route.admin').'.admin');

        // 角色管理
        Route::group('role',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
            // 所有权限
            Route::get('/getAuth','/getAuth');
        })->prefix(config('route.admin').'.role');

        // 网站管理
        Route::group('website',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.website');

        // 模型管理
        Route::group('module',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.module');

        // 模型字段管理
        Route::group('moduleField',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
            Route::get('/list','/list');
        })->prefix(config('route.admin').'.moduleField');

        // 栏目管理
        Route::group('category',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
            // 模型下的所有栏目
            Route::get('/getModuleCate','/getModuleCate');
        })->prefix(config('route.admin').'.category');

        // 前台导航分类管理
        Route::group('navCate',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.navCate');

        // 前台导航管理
        Route::group('nav',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.nav');

        // 内容管理
        Route::group('content',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
            // 获取新增内容字段
            Route::get('/create','/create');
            // 获取副表内容
            Route::get('/mainContent','/mainContent');
            // 置顶 取消置顶 推荐  取消推荐
            Route::post('/topOpt','/topOpt');
            Route::post('/recommendAndStatus','/recommendAndStatus');
            // 内链添加
            Route::post('/addInnerChat','/addInnerChat');

        })->prefix(config('route.admin').'.content');

        // 标签管理
        Route::group('tag',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.tag');

        // 友情链接管理
        Route::group('link',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
            // 复制其他站点友情链接
            Route::post('/copy','/link');
        })->prefix(config('route.admin').'.link');

        // 友情链接管理
        Route::group('sysSetting',function(){
            Route::get('/index','/index');
            Route::post('/update','/update');
        })->prefix(config('route.admin').'.sysSetting');

        // 后台菜单管理
        Route::group('adminMenu',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.adminMenu');

        // 日志管理
        Route::get('/adminLoginLog/index',config('route.admin').'.adminLoginLog/index');
        Route::get('/adminOptLog/index',config('route.admin').'.adminOptLog/index');

        // 网站配置
        Route::group('websiteSetting',function(){
            Route::get('/read','/read');
            Route::post('/update','/update');
        })->prefix(config('route.admin').'.websiteSetting');

        // 网站配置
        // 基本配置
        Route::group('websiteSetting',function(){
            Route::get('/read','/read');
            Route::post('/update','/update');
        })->prefix(config('route.admin').'.websiteSetting');
        // 语言配置
        Route::group('websiteLang',function(){
            Route::get('/system','/system');
            Route::get('/index','/index');
            Route::post('/save','/save');
        })->prefix(config('route.admin').'.websiteLang');
        // 服务器配置
        Route::group('websiteServer',function(){
            Route::post('/save','/save');
            Route::get('/read','/read');
            Route::post('/update','/update');
        })->prefix(config('route.admin').'.websiteServer');

        // 数据库备份
        Route::group('database',function(){
            Route::post('/backup','/backup');
            Route::post('/restore','/restore');
            Route::get('/tableList','/tableList');
            Route::get('/index','/index');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.database');

        // 回收站管理
        Route::group('recycleBin',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::post('/clean','/clean');
            Route::post('/delete','/delete');
            Route::post('/restore','/restore');
            Route::post('/allRestore','/allRestore');
        })->prefix(config('route.admin').'.recycleBin');

        // 网站模版管理
        Route::group('theme',function(){
            Route::get('/install','/install');
            Route::post('/installTheme','/installTheme');
            Route::get('/index','/index');
            Route::post('/active','/active');
            Route::post('/update','/update');
            Route::post('/uninstall','/uninstall');
            Route::get('/allFilePath','/allFilePath');
            Route::get('/allFiles','/allFiles');
            Route::get('/tmpFile','/tmpFile');
        })->prefix(config('route.admin').'.theme');

        // 模版文件管理
        Route::group('themeFile',function(){
            Route::post('/design','/design');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::get('/active','/active');
        })->prefix(config('route.admin').'.themeFile');

        // 附件管理
        Route::group('attachment',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::post('/uploadAndSave','/uploadAndSave');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.attachment');

        // 询盘管理
        Route::group('inquiry',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.inquiry');

        // 询盘分类管理
        Route::group('inquiryCategory',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.inquiryCategory');

        // 询盘收件箱
        Route::group('inquiryEmail',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.inquiryEmail');

        // 关键词管理
        Route::group('keyword',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
            Route::post('/import','/import');
            Route::get('/template','/template');
            Route::get('/monitor','/monitor');
        })->prefix(config('route.admin').'.keyword');
        // 关键词管理
        Route::group('keywordQuery',function(){
            // 关键词监控
            Route::get('/index','/index');
            Route::post('/save','/save');

        })->prefix(config('route.admin').'.keywordQuery');

        // 内链管理
        Route::group('innerChart',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.innerChart');

        // 广告管理
        Route::group('advertisement',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.advertisement');

        // 友情链接管理
        Route::group('link',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.link');

        // 百度统计
        Route::group('statistics',function(){
            Route::get('/lists','/lists');          // 站点列表
            Route::get('/age','/age');              // 访问者年龄
            Route::get('/outline','/outline');      // 今日昨日浏览量分析
            Route::get('/qxt','/qxt');             // 趋势图
            Route::get('/search_word','/search_word');     // 关键词消费排名
            Route::get('/get_common_track_rpt','/get_common_track_rpt');    // 网站概况(来源网站、搜索词、入口页面、受访页面、新老访客)
            Route::get('/area','/area');            // 网站概况(地域分布)
            Route::get('/area_top','/area_top');    // 网站概况(地域分布Top10)
        })->prefix(config('route.admin').'.statistics');
        // 谷歌统计


        // 职位管理
        Route::group('job',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.job');

        // 职位分类管理
        Route::group('jobCate',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.jobCate');

        // 职位城市管理
        Route::group('jobCity',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.jobCity');

        // 文件上传
        Route::post('/upload/save',config('route.admin').'.Upload/save');
        // 控制面板
        Route::get('/dashboard/index',config('route.admin').'.dashboard/index');

        // 幻灯片分类
        Route::group('slideCate',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.slideCate');
        // 幻灯片列表
        Route::group('slide',function(){
            Route::post('/save','/save');
            Route::get('/index','/index');
            Route::get('/read','/read');
            Route::post('/update','/update');
            Route::post('/delete','/delete');
        })->prefix(config('route.admin').'.slide');

    })->middleware('login');
});

Route::miss(function() {
    if (!file_exists(APP_PATH  . '/data/install.lock')) {
        return redirect('/install');
    }

    return '404 Not Found!';
});
    
    
